package ru.myrtle.umf.impl;

import java.util.*;
import ru.myrtle.umf.*;
import ru.myrtle.umf.util.*;

public class UAttributeImpl extends UObjectImpl implements UAttribute {

    protected static final boolean IDENTIFYING_ATTRIBUTE_DEFAULT = Boolean.FALSE;
    protected static final boolean TRANSIENT_DEFAULT = Boolean.FALSE;
    protected static final boolean VOLATILE_DEFAULT = Boolean.FALSE;
    protected static final boolean CHANGEABLE_DEFAULT = Boolean.FALSE;
    protected static final boolean DERIVED_DEFAULT = Boolean.FALSE;
    protected static final String NAME_DEFAULT = null;
    protected static final String DESCRIPTION_DEFAULT = null;

    public UAttributeImpl() {
    }

    @Override
    public UClass uClass() {
        return UModel.UATTRIBUTE;
    }
    
    private UDataType _type_;

    @Override
    public final UDataType getType() {
        return _type_;
    }

    @Override
    public final boolean isSetType() {
        return _type_ != null;
    }

    private void setTypeImpl(UDataType _type_) {
        this._type_ = _type_;
    }

    @Override
    public final void setType(UDataType _type_) {
        if (this._type_ != _type_) {
                                                                    setTypeImpl(_type_);
                                                                }
    }
    
    @Override
    public final void unsetType() {
        setTypeImpl(null);
    }

    private boolean _identifyingAttribute_ = IDENTIFYING_ATTRIBUTE_DEFAULT;

    @Override
    public final boolean isIdentifyingAttribute() {
        return _identifyingAttribute_;
    }

    @Override
    public final boolean isSetIdentifyingAttribute() {
        return _identifyingAttribute_ != IDENTIFYING_ATTRIBUTE_DEFAULT;
    }

    @Override
    public final void setIdentifyingAttribute(boolean _identifyingAttribute_) {
        this._identifyingAttribute_ = _identifyingAttribute_;
    }

    @Override
    public final void unsetIdentifyingAttribute() {
        _identifyingAttribute_ = IDENTIFYING_ATTRIBUTE_DEFAULT;
    }

    private boolean _transient_ = TRANSIENT_DEFAULT;

    @Override
    public final boolean isTransient() {
        return _transient_;
    }

    @Override
    public final boolean isSetTransient() {
        return _transient_ != TRANSIENT_DEFAULT;
    }

    @Override
    public final void setTransient(boolean _transient_) {
        this._transient_ = _transient_;
    }

    @Override
    public final void unsetTransient() {
        _transient_ = TRANSIENT_DEFAULT;
    }

    private boolean _volatile_ = VOLATILE_DEFAULT;

    @Override
    public final boolean isVolatile() {
        return _volatile_;
    }

    @Override
    public final boolean isSetVolatile() {
        return _volatile_ != VOLATILE_DEFAULT;
    }

    @Override
    public final void setVolatile(boolean _volatile_) {
        this._volatile_ = _volatile_;
    }

    @Override
    public final void unsetVolatile() {
        _volatile_ = VOLATILE_DEFAULT;
    }

    private boolean _changeable_ = CHANGEABLE_DEFAULT;

    @Override
    public final boolean isChangeable() {
        return _changeable_;
    }

    @Override
    public final boolean isSetChangeable() {
        return _changeable_ != CHANGEABLE_DEFAULT;
    }

    @Override
    public final void setChangeable(boolean _changeable_) {
        this._changeable_ = _changeable_;
    }

    @Override
    public final void unsetChangeable() {
        _changeable_ = CHANGEABLE_DEFAULT;
    }

    private boolean _derived_ = DERIVED_DEFAULT;

    @Override
    public final boolean isDerived() {
        return _derived_;
    }

    @Override
    public final boolean isSetDerived() {
        return _derived_ != DERIVED_DEFAULT;
    }

    @Override
    public final void setDerived(boolean _derived_) {
        this._derived_ = _derived_;
    }

    @Override
    public final void unsetDerived() {
        _derived_ = DERIVED_DEFAULT;
    }

    private UClass _containingClass_;

    @Override
    public final UClass getContainingClass() {
        return _containingClass_;
    }

    @Override
    public final boolean isSetContainingClass() {
        return _containingClass_ != null;
    }

    private void setContainingClassImpl(UClass _containingClass_) {
        this._containingClass_ = _containingClass_;
    }

    private String _name_ = NAME_DEFAULT;

    @Override
    public final String getName() {
        return _name_;
    }

    @Override
    public final boolean isSetName() {
        return _name_ != NAME_DEFAULT;
    }

    @Override
    public final void setName(String _name_) {
        this._name_ = _name_;
    }

    @Override
    public final void unsetName() {
        _name_ = NAME_DEFAULT;
    }

    private String _description_ = DESCRIPTION_DEFAULT;

    @Override
    public final String getDescription() {
        return _description_;
    }

    @Override
    public final boolean isSetDescription() {
        return _description_ != DESCRIPTION_DEFAULT;
    }

    @Override
    public final void setDescription(String _description_) {
        this._description_ = _description_;
    }

    @Override
    public final void unsetDescription() {
        _description_ = DESCRIPTION_DEFAULT;
    }

    private UList<UAnnotation> _annotations_;

    @Override
    public final UList<UAnnotation> getAnnotations() {
        if (_annotations_ == null) {
            _annotations_ = new UObjectContainmentList<UAnnotation>(this, UModel.UELEMENT__ANNOTATIONS);
        }
        return _annotations_;
    }

    @Override
    public final boolean isSetAnnotations() {
        return _annotations_ != null && !_annotations_.isEmpty();
    }

    @Override
    public void setAnnotations(UList<UAnnotation> _annotations_) {
        getAnnotations().clear();
        getAnnotations().addAll(_annotations_);
    }

    @Override
    public void unsetAnnotations() {
        if (_annotations_ != null) {
            _annotations_.clear();
        }
    }


    @Override
    @SuppressWarnings(
        "unchecked"
    )
    public Object uGet(UFeature feature) {
        if (feature == UModel.UATTRIBUTE__TYPE) {
            return getType();
        }
        if (feature == UModel.UATTRIBUTE__IDENTIFYING_ATTRIBUTE) {
            return isIdentifyingAttribute();
        }
        if (feature == UModel.UFEATURE__TRANSIENT) {
            return isTransient();
        }
        if (feature == UModel.UFEATURE__VOLATILE) {
            return isVolatile();
        }
        if (feature == UModel.UFEATURE__CHANGEABLE) {
            return isChangeable();
        }
        if (feature == UModel.UFEATURE__DERIVED) {
            return isDerived();
        }
        if (feature == UModel.UFEATURE__CONTAINING_CLASS) {
            return getContainingClass();
        }
        if (feature == UModel.UELEMENT__NAME) {
            return getName();
        }
        if (feature == UModel.UELEMENT__DESCRIPTION) {
            return getDescription();
        }
        if (feature == UModel.UELEMENT__ANNOTATIONS) {
            return getAnnotations();
        }

        return super.uGet(feature);
    }

    @Override
    @SuppressWarnings(
        "unchecked"
    )
    public boolean uIsSet(UFeature feature) {
        if (feature == UModel.UATTRIBUTE__TYPE) {
            return isSetType();
        }
        if (feature == UModel.UATTRIBUTE__IDENTIFYING_ATTRIBUTE) {
            return isSetIdentifyingAttribute();
        }
        if (feature == UModel.UFEATURE__TRANSIENT) {
            return isSetTransient();
        }
        if (feature == UModel.UFEATURE__VOLATILE) {
            return isSetVolatile();
        }
        if (feature == UModel.UFEATURE__CHANGEABLE) {
            return isSetChangeable();
        }
        if (feature == UModel.UFEATURE__DERIVED) {
            return isSetDerived();
        }
        if (feature == UModel.UFEATURE__CONTAINING_CLASS) {
            return isSetContainingClass();
        }
        if (feature == UModel.UELEMENT__NAME) {
            return isSetName();
        }
        if (feature == UModel.UELEMENT__DESCRIPTION) {
            return isSetDescription();
        }
        if (feature == UModel.UELEMENT__ANNOTATIONS) {
            return isSetAnnotations();
        }

        return super.uIsSet(feature);
    }

    @Override
    @SuppressWarnings(
        "unchecked"
    )
    public void uSet(UFeature feature, Object value) {
        if (feature == UModel.UATTRIBUTE__TYPE) {
            setType((UDataType) value);
            return;
        }
        if (feature == UModel.UATTRIBUTE__IDENTIFYING_ATTRIBUTE) {
            setIdentifyingAttribute(((Boolean) value).booleanValue());
            return;
        }
        if (feature == UModel.UFEATURE__TRANSIENT) {
            setTransient(((Boolean) value).booleanValue());
            return;
        }
        if (feature == UModel.UFEATURE__VOLATILE) {
            setVolatile(((Boolean) value).booleanValue());
            return;
        }
        if (feature == UModel.UFEATURE__CHANGEABLE) {
            setChangeable(((Boolean) value).booleanValue());
            return;
        }
        if (feature == UModel.UFEATURE__DERIVED) {
            setDerived(((Boolean) value).booleanValue());
            return;
        }
        if (feature == UModel.UELEMENT__NAME) {
            setName((String) value);
            return;
        }
        if (feature == UModel.UELEMENT__DESCRIPTION) {
            setDescription((String) value);
            return;
        }
        if (feature == UModel.UELEMENT__ANNOTATIONS) {
            setAnnotations((UList<UAnnotation>) value);
            return;
        }

        super.uSet(feature, value);
    }

    @Override
    @SuppressWarnings(
        "unchecked"
    )
    public void uUnset(UFeature feature) {
        if (feature == UModel.UATTRIBUTE__TYPE) {
            unsetType();
            return;
        }
        if (feature == UModel.UATTRIBUTE__IDENTIFYING_ATTRIBUTE) {
            unsetIdentifyingAttribute();
            return;
        }
        if (feature == UModel.UFEATURE__TRANSIENT) {
            unsetTransient();
            return;
        }
        if (feature == UModel.UFEATURE__VOLATILE) {
            unsetVolatile();
            return;
        }
        if (feature == UModel.UFEATURE__CHANGEABLE) {
            unsetChangeable();
            return;
        }
        if (feature == UModel.UFEATURE__DERIVED) {
            unsetDerived();
            return;
        }
        if (feature == UModel.UELEMENT__NAME) {
            unsetName();
            return;
        }
        if (feature == UModel.UELEMENT__DESCRIPTION) {
            unsetDescription();
            return;
        }
        if (feature == UModel.UELEMENT__ANNOTATIONS) {
            unsetAnnotations();
            return;
        }

        super.uUnset(feature);
    }


    @Override
    @SuppressWarnings(
        "unchecked"
    )
    public void uInternalInverseAdd(UObject otherEnd, UReference reference) {
        if (reference == UModel.UFEATURE__CONTAINING_CLASS) {
            setContainingClassImpl((UClass) otherEnd);
            return;
        }
    }

    @Override
    @SuppressWarnings(
        "unchecked"
    )
    public void uInternalInverseRemove(UObject otherEnd, UReference reference) {
        if (reference == UModel.UFEATURE__CONTAINING_CLASS) {
            setContainingClassImpl(null);
            return;
        }
    }


    @Override
    public Object getValue(UObject object) {
        return UAttributeOperations.INSTANCE.getValue(this, object);
    }

    @Override
    public void setValue(UObject object, Object value) {
        UAttributeOperations.INSTANCE.setValue(this, object, value);
    }

    @Override
    public String toString() {
        StringBuffer result = new StringBuffer();

        result.append("UAttribute");
        result.append(" (");
        result.append("identifyingAttribute: ");
        result.append(_identifyingAttribute_);
        result.append(", ");
        result.append("transient: ");
        result.append(_transient_);
        result.append(", ");
        result.append("volatile: ");
        result.append(_volatile_);
        result.append(", ");
        result.append("changeable: ");
        result.append(_changeable_);
        result.append(", ");
        result.append("derived: ");
        result.append(_derived_);
        result.append(", ");
        result.append("name: ");
        result.append(_name_);
        result.append(", ");
        result.append("description: ");
        result.append(_description_);
        result.append(')');

        return result.toString();
    }
}




